package com.fmy.test.config.dynamic.handler;

import com.fmy.test.config.dynamic.enums.DBType;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @Auther: Mr.fmy
 * @Date: 2019/8/25 0025 11:49
 * @Description: <p>
 * 动态数据源选择规范默认处理接口
 * </p>
 */
public class DefultDynamicHandler implements DynamicHandler {

    @Override
    public DBType dynamicHolder(String methodName) {
        Assert.notNull(methodName, "传入方法名不可为空");
        if (methodName.startsWith("find") || methodName.startsWith("list") || methodName.startsWith("get")) {
            return DBType.READ_DB;
        } else {
            return DBType.WRITE_DB;
        }
    }
}
